<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns a tree of threaded message</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.imap-thread" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imap_thread</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.7, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">imap_thread</span> &mdash; <span class="dc-title">Returns a tree of threaded message</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imap-thread-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imap_thread</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$imap_stream</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = SE_FREE</span></span>
  ] ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
   Gets a tree of a threaded message.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imap-thread-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<code class="parameter">
imap_stream</code></dt>
<dd>
<p class="para">由 <span class="function"><a href="imap_open.html" class="function">imap_open()</a></span> 返回的 IMAP 流。</p></dd>

    
     <dt>
<code class="parameter">options</code></dt>

     <dd>

      <p class="para">
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imap-thread-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   <span class="function"><strong>imap_thread()</strong></span> returns an associative array containing
   a tree of messages threaded by <em>REFERENCES</em>, or <strong><code>FALSE</code></strong>
   on error.
  </p>
  <p class="para">
   Every message in the current mailbox will be represented by three entries
   in the resulting array:
   <ul class="itemizedlist">
    <li class="listitem"><p class="para">
     <var class="varname"><var class="varname">$thread["XX.num"]</var></var> - current message number
    </p></li>
    <li class="listitem"><p class="para">
     <var class="varname"><var class="varname">$thread["XX.next"]</var></var>
    </p></li>
    <li class="listitem"><p class="para">
     <var class="varname"><var class="varname">$thread["XX.branch"]</var></var>
    </p></li>
   </ul>
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.imap-thread-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4040">
    <p><strong>Example #1 <span class="function"><strong>imap_thread()</strong></span> Example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;Here&nbsp;we're&nbsp;outputting&nbsp;the&nbsp;threads&nbsp;of&nbsp;a&nbsp;newsgroup,&nbsp;in&nbsp;HTML<br /><br /></span><span style="color: #0000BB">$nntp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imap_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'{news.example.com:119/nntp}some.newsgroup'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$threads&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imap_thread</span><span style="color: #007700">(</span><span style="color: #0000BB">$nntp</span><span style="color: #007700">);<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$threads&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$key&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$tree&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">'.'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$key</span><span style="color: #007700">);<br />&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$tree</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]&nbsp;==&nbsp;</span><span style="color: #DD0000">'num'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$header&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imap_headerinfo</span><span style="color: #007700">(</span><span style="color: #0000BB">$nntp</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$val</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;ul&gt;\n\t&lt;li&gt;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$header</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fromaddress&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}&nbsp;elseif&nbsp;(</span><span style="color: #0000BB">$tree</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">]&nbsp;==&nbsp;</span><span style="color: #DD0000">'branch'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"\t&lt;/li&gt;\n&lt;/ul&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">imap_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$nntp</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

</div></div></div></body></html>